package com.xxxx.portal.service.Impl;

import com.xxxx.api.utils.CookieUtil;
import com.xxxx.portal.service.CookieService;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author : ymd
 * @Date : 2020/11/2 0002 15:54
 * @Version 1.0
 * @Description : 实现类
 */
@Service
public class CookieServiceImpl implements CookieService {
    @Override
    public boolean setCookie(HttpServletRequest request, HttpServletResponse response, String ticket) {
        try {
            CookieUtil.setCookie("ticket", ticket, "", response);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public String getCookie(HttpServletRequest request) {
        return CookieUtil.getCookieValue(request, "ticket");
    }

    @Override
    public boolean deleteCookie(HttpServletRequest request, HttpServletResponse response) {
        try {
            CookieUtil.deleteCookie("ticket", request, response);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

}
